package ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.presentation.controller.admin;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;

import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.presentation.controller.admin.users.UserBean;

@ManagedBean(name="userInfoBean")
@ViewScoped
public class UserInfoBean {
	
	@ManagedProperty(value="#{flash.selectedUser}")
	private UserBean selectedUser;

	public void forwardUsersIfNotSelection(ComponentSystemEvent cse) {
		FacesContext faceContext = FacesContext.getCurrentInstance();
		if (selectedUser == null) {
			faceContext.getApplication().getNavigationHandler().
		handleNavigation(faceContext, null,	"/adminuser/users?faces-redirect=true");
		}
	}
	
	public UserBean getSelectedUser() {
		return selectedUser;
	}

	public void setSelectedUser(UserBean selectedUser) {
		this.selectedUser = selectedUser;
	}

}
